package com.joysuch.wwyt.edu.enums;

/**
 * 分配问题 类型
 */
public enum DistributionQuestionTypes {


    SINGLE("S", "单选题"),
    MULTI_CHOICE("M", "多选题"),
    ZG_CHOICE("Z", "主观题"),
    JUDGE("J", "判断题"),

    RANDOM_CONTAIN_ZG_CHOICE("RC", "随机包含主观题"),

    RANDOM_NOT_ZG_CHOICE("RN", "随机不包含主观题");

    private String code;
    private String name;

    private DistributionQuestionTypes(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public boolean is(String code) {
        return this.code.equals(code);
    }

    public static DistributionQuestionTypes findByName(String name) {
        DistributionQuestionTypes[] values = DistributionQuestionTypes.values();
        for (DistributionQuestionTypes v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static DistributionQuestionTypes findByCode(String code) {
        DistributionQuestionTypes[] values = DistributionQuestionTypes.values();
        for (DistributionQuestionTypes v : values) {
            if (v.getCode().equals(code)) {
                return v;
            }
        }
        return null;
    }

    public static String findNameByCode(String code) {
        DistributionQuestionTypes types = findByCode(code);
        return types == null ? null : types.name;
    }
}
